package zh.javadesign.抽象工厂.scene.matter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

/**
 * Copyright (C) 广州中和互联网技术有限公司
 *
 * @author 范家微 fanjiawei@borche.cn
 * @date :2021/2/2 21:23
 */
public class RedisUtils {
	private Logger logger = LoggerFactory.getLogger(RedisUtils.class);
	private Map<String, String> dataMap = new ConcurrentHashMap<>();

	public String get(String key) {
		logger.info("redis获取数据:{}", key);
		return dataMap.get(key);
	}

	public void set(String key, String value) {
		logger.info("redis写入数据key:{},value:{}", key, value);
		dataMap.put(key, value);
	}

	public void set(String key, String value, long timeout, TimeUnit timeUnit) {
		logger.info("redis写入数据key:{},value:{} timeout:{},timeUnit:{}", key, value, timeout, timeUnit.toString());
	}

	public void del(String key) {
		logger.info("redis删除数据 key:{}", key);
		dataMap.remove(key);
	}
}
